public class O54 {
    int count,target;
    public int kthLargest(TreeNode root, int k) {
        count = 0;
        target = Integer.MIN_VALUE;
        dfs(root,k);
        return target;
    }
    void dfs(TreeNode node,int k){
        if (node == null)
            return;
        if (target!=Integer.MIN_VALUE)
            return;
        dfs(node.left, k);
        count++;
        if (count==k-1)
            target = node.val;

        dfs(node.right, k);
    }
}
